'use strict';

const ObjectId = require('mongodb').ObjectId;

module.exports = app => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;

  const articlesSchema = new Schema({
    title: String,
    type: String,
    time: String,
    lastModify: String,
    recommend: Number,
    banner: String,
    status: Number,
    author: ObjectId,
    post: String,
    comment: [
      {
        key: String,
        content: String,
        owner: ObjectId,
        createTime: String,
        status: Number,
      },
    ],
    liked: Array,
    favorited: Array,
  });

  return mongoose.model('articles', articlesSchema, 'articles');
};
